package com.vito.oa.preview.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import com.alibaba.dubbo.config.annotation.Service;
import com.vito.oa.preview.dao.PreviewFileMapper;
import com.vito.oa.preview.model.PreviewFileModel;
import com.vito.oa.preview.service.PreviewFileService;

@Service
public class PreviewFileServiceImpl implements PreviewFileService {

	@Autowired
	private PreviewFileMapper previewFileMapper;
	
	@Override
	public boolean savePreviewFile(PreviewFileModel model) {
		if(previewFileMapper.getPreviewFileCount(model.getFileId())>0){
			previewFileMapper.deletePreviewFile(model.getFileId());
		};
		return previewFileMapper.savePreviewFile(model);
	}

	@Override
	public PreviewFileModel getPreviewPath(String fileId) {
		
		return previewFileMapper.getPreviewPath(fileId);
	}

	@Override
	public List<PreviewFileModel> getPreviewFileById(String fileId) {
		
		return previewFileMapper.getPreviewFileById(fileId);
	}

	@Override
	public int getPreviewFileCount(String fileId) {
		
		return previewFileMapper.getPreviewFileCount(fileId);
	}

	@Override
	public boolean deletePreviewPath(String fileId) {
		return previewFileMapper.deletePreviewFile(fileId);
	}
	
}
